package symbols;
import java.util.*; import lexer.*; import inter.*;

public class Env {

	private Hashtable table;
	protected Env prev;

	public Env(Env n) { table = new Hashtable(); prev = n; }

	public void put(Token w, Id i) { table.put(w, i); }

	public Id get(Token w) {
		for( Env e = this; e != null; e = e.prev ) {
			Id found = (Id)(e.table.get(w));
			if( found != null ) return found;
		}
		return null;
	}

	public static class Array extends Type {
	   public Type of;                  // array *of* type
	   public int size = 1;             // number of elements
	   public Array(int sz, Type p) {
		  super("[]", Tag.INDEX, sz*p.width); size = sz;  of = p;
	   }
	   public String toString() { return "[" + size + "] " + of.toString(); }
	}
}
